package lcr;

import java.util.HashSet;

class Solution0120_1 {
    public int findRepeatDocument(int[] documents) {
        int n = documents.length;
        int i=0;
        while (i < n) {
            if (documents[i] == i) {
                i++;
                continue;
            }
            if (documents[documents[i]] == documents[i]) {
                return documents[i];
            }
            int t = documents[i];
            documents[i] = documents[t];
            documents[t] = t;
        }
        return -1;
    }
}